<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>数据上报系统</title>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/index.css" />
		<link rel="stylesheet" href="__PUBLIC__/Home/css/list.css" />
		<script src="__PUBLIC__/assets/js/jquery.min.js"></script>
		<script src="__PUBLIC__/assets/js/jquery.form.js"></script>
		<script src="__PUBLIC__/Home/js/table_411.js"></script>
		<script src="__PUBLIC__/Home/js/table_409.js"></script>
		<script src="__PUBLIC__/Home/js/table_410.js"></script>
		<script src="__PUBLIC__/Home/js/table_414.js"></script>
		<script src="__PUBLIC__/layer/layer.js"></script>
		<script src="__PUBLIC__/assets/js/bootstrap.js"></script>		
		<link rel="stylesheet" href="__PUBLIC__/assets/css/bootstrap.css" />
	</head>

	<body>

		<div class="row rowList rowHeader">
			<div class="header1">
				<span class="myIcon" style="margin-right: 5px;">&#xe626;</span>你好，<span id="userName"><php>echo $_SESSION['c_user']</php></span>！
				<a style="color:white;text-decoration: none;" href="{:U('index/loginout')}"><span id="cancel"><span class="myIcon">&#xe611;</span>注销</span></a>
			</div>
			<div class="">
				<img style="height: 40px; margin: 10px 0;" src="__PUBLIC__/Home/img/logo2.png" />
			</div>

		</div>
		                                <div class="modal fade" id="city" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-hidden="true">×
                                    </button>
                                    <h4 class="modal-title" id="myModalLabel">
                                        选择国内城市
                                    </h4>
                                </div>
                                <div class="modal-body">
                                    <div class="row">
                                        <div class="col-xs-12">
                                        <form>
                                <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">


                                    <tr>
                                        <td height="30"  style="border-bottom:#CCCCCC solid 1px; line-height:25px; background-color:#F4F8FB">
                                            <label>
                                                <input type="checkbox" class="ace ace-checkbox-2"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
                                                <span class="lbl"> 全选</span>
                                            </label>
                                        </td>


                                    </tr>
                                    <tr>


                                            <td class="company_info" height="30" style="padding-left:70px;border-bottom:#E7EBF8 dashed 1px; color:#666666">

                                                <volist name="city" id="vo">
                                                    <label class="thopen">
                                                        <input name="city[]" class="ace ace-checkbox-2 checkbox-child" type="checkbox"  id="{$vo.id}" value="{$vo.name}"  />
                                                    <span class="lbl" style="margin-right:10px;">{$vo.name}</span>
                                                    </label>
                                                </volist>

                                            </td>


                                    </tr>

                                </table>
                                </form>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <input type="button" id="cityadd" class="btn btn-primary" data-id=""  value="插入"/>
    
                                    <button type="button" class="btn btn-default" data-dismiss="modal">
                                        关闭
                                    </button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                </div>
                </div>
                                <div class="modal fade" id="goods" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-hidden="true">×
                                    </button>
                                    <h4 class="modal-title" id="myModalLabel">
                                        选择商品分类
                                    </h4>
                                </div>
                                <div class="modal-body">
                                    <div class="row">
                                        <div class="col-xs-12">
                                        <form>
                                <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">


                                    <tr>
                                        <td height="30"  style="border-bottom:#CCCCCC solid 1px; line-height:25px; background-color:#F4F8FB">
                                            <label>
                                                <input type="checkbox" class="ace ace-checkbox-2"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
                                                <span class="lbl"> 全选</span>
                                            </label>
                                        </td>


                                    </tr>
                                    <tr>


                                            <td class="company_info" height="30" style="padding-left:70px;border-bottom:#E7EBF8 dashed 1px; color:#666666">

                                                <volist name="goods" id="vo">
                                                    <label class="thopen">
                                                        <input name="goods[]" class="ace ace-checkbox-2 checkbox-child" type="checkbox"  id="{$vo.id}" value="{$vo.name}"  />
                                                    <span class="lbl" style="margin-right:10px;">{$vo.name}</span>
                                                    </label>
                                                </volist>

                                            </td>


                                    </tr>

                                </table>
                                </form>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <input type="button" id="goodsadd" class="btn btn-primary" data-id=""  value="插入"/>
    
                                    <button type="button" class="btn btn-default" data-dismiss="modal">
                                        关闭
                                    </button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                </div>
                <div class="modal fade" id="country" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"
                                            aria-hidden="true">×
                                    </button>
                                    <h4 class="modal-title" id="myModalLabel">
                                        选择国家地区
                                    </h4>
                                </div>
                                <div class="modal-body">
                                    <div class="row">
                                        <div class="col-xs-12">
                                        <form>
                                <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">


                                    <tr>
                                        <td height="30"  style="border-bottom:#CCCCCC solid 1px; line-height:25px; background-color:#F4F8FB">
                                            <label>
                                                <input type="checkbox" class="ace ace-checkbox-2"  id='chkAll' onclick='CheckAll(this.form)' value="全选"/>
                                                <span class="lbl"> 全选</span>
                                            </label>
                                        </td>


                                    </tr>
                                    <tr>


                                            <td class="company_info" height="30" style="padding-left:70px;border-bottom:#E7EBF8 dashed 1px; color:#666666">

                                                <volist name="country" id="vo">
                                                    <label class="thopen">
                                                        <input name="country[]" class="ace ace-checkbox-2 checkbox-child" type="checkbox"  id="{$vo.id}" value="{$vo.name}"  />
                                                    <span class="lbl" style="margin-right:10px;">{$vo.name}</span>
                                                    </label>
                                                </volist>

                                            </td>


                                    </tr>

                                </table>
                                </form>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <input type="button" id="countryadd" class="btn btn-primary" data-id=""  value="插入"/>
    
                                    <button type="button" class="btn btn-default" data-dismiss="modal">
                                        关闭
                                    </button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                </div>
		<div class="row rowB">
			<div class="rowL">
				<ul id="state">
					<li>
						<div class="stateType">
							新报表任务
						</div>
						<ul class="list">
                            <volist name="w_table" id="v">
                                <li class="">
									<if condition="$v['id'] neq $info['id']"><a style="text-decoration: none;" href="{:U('index/table',array('id'=>$v['id']))}"></if>
										<div class="listType">{$v.title}({$v.year}年{$v.quarter}季度)</div>
									<if condition="$v['id'] neq $info['id']"></a></if>
										<ul class="listDetail" <if condition="$v['id'] eq $info['id']">style="display:block;"</if> >
											<li class="chooseLi">在线填报</li>
										</ul>

                                </li>
                            </volist>
						</ul>

					</li>
				<li>
					<div class="stateType">
						审核中
					</div>
					<ul class="list">
						<volist name="d_table" id="v">
							<li class="">
								<a style="text-decoration: none;" href="{:U('index/d_table',array('id'=>$v['id']))}">
									<div class="listType">{$v.title}({$v.year}年{$v.quarter}季度)</div>
								</a>
							</li>
						</volist>
					</ul>

				</li>
				<li>
					<div class="stateType">
						未通过
					</div>
					<ul class="list" style="display: block;">
						<volist name="n_table" id="v">
							<li class="">
								<if condition="$v['id'] neq $info['id']"><a style="text-decoration: none;" href="{:U('index/n_table',array('id'=>$v['id']))}"></if>
								<div class="listType">{$v.title}({$v.year}年{$v.quarter}季度)</div>
								<if condition="$v['id'] neq $info['id']"></a></if>
								<ul class="listDetail" <if condition="$v['id'] eq $info['id']">style="display:block;"</if> >
										<li class="chooseLi">在线填报</li>
								</ul>
							</li>
						</volist>
					</ul>

				</li>
				<li>
					<div class="stateType">
						已过期
					</div>
					<ul class="list">
						<volist name="e_table" id="v">
							<li class="">
								<a style="text-decoration: none;" href="{:U('index/e_table',array('id'=>$v['id']))}">
									<div class="listType">{$v.title}({$v.year}年{$v.quarter}季度)</div>
								</a>
							</li>
						</volist>
					</ul>

				</li>
					<li>
						<div class="stateType">
							历史报表
						</div>
						<ul class="list list2">
                            <volist name="y_table" id="y">
                                <li class="">
									<a style="text-decoration: none;" href="{:U('index/w_table',array('id'=>$y['id']))}">
                                    	<div class="listType">{$y.title}({$y.year}年{$y.quarter}季度)</div>
									</a>
                                </li>
                            </volist>
						</ul>

					</li>
				</ul>
			</div>
			<div class="rowR">
				<!--在线填写-->
				<div id="onLine"   style="display: block;">

					<form action="{:U('online_run')}" method="post" id="form1" >
						<input type="hidden" name="tableid" value="{$info.id}" >
						<div id="tableDetail">
							<div class="title">
								<div class="titltLeft">
									<h3>{$info['title']}({$info['code']}表)</h3>
								</div>

							</div>
							<div>
								<div class="unit"  style="float: left;margin-top: 80px">
									填报单位：{$info['target']}
									&nbsp;
									<span>年份季度：{$info['year']}年<if condition="$info['quarter'] eq 1">1<else/>1-{$info['quarter']}</if>季度</span>
								</div>
								<div class="titltRight"  style="float: right;">
									<ul>
										<li>表&emsp;&emsp;号：{$info['code']}表</li>
										<li>制定机关：</li>
										<li>批准机关：</li>
										<li>批准文号：</li>
										<li>有效期至：{$info.endtime|date="y-m-d",###}</li>
									</ul>
								</div>
							</div>
							<div id="table">

								<table border="1" cellspacing="0" cellpadding="0" width="100%" frame="hsides">
									<tbody>
									<tr class="level1">
										<td width="30%">指标名称</td>
										<td width="10%">计量单位</td>
										<td width="10%">代码</td>
										<td width="25%">上年<if condition="$info['quarter'] eq 1">1<else/>1-{$info['quarter']}</if>季度</td>
										<td width="25%">本年<if condition="$info['quarter'] eq 1">1<else/>1-{$info['quarter']}</if>季度</td>
									</tr>
									<tr class="level1">
										<td>甲</td>
										<td>乙</td>
										<td>丙</td>
										<td>1</td>
										<td>2</td>
									</tr>

									<foreach name="res" item="v">
										<tr <if condition="$v.code eq '--'">class="level1"<else/>class="level2"</if>>
											<td>{$v.name}</td>
											<td>{$v.metering}</td>
											<td>{$v.code}</td>

											<if condition="$key eq 'd5'">
												<td>
                                                <select style="width: 100%; <if condition="$v.last_update eq 'true'">color:red</if>" name="last[]">
                                                    <option value="">选择类别</option>
                                                    <volist name="xj_type" id="vv">
                                                        <option <if condition="$vv['name'] eq $v['last']">selected="selected"</if> value="{$vv.name}">{$vv.name}</option>
                                                    </volist>
                                                    
                                                    
                                                </select>
                                            </td>

                                            <td>
                                                <select style="width: 100%; <if condition="$v.now_update eq 'true'">color:red</if>" name="now[]">
                                                    <option value="">选择类别</option>
                                                    <volist name="xj_type" id="vv">
                                                        <option <if condition="$vv['name'] eq $v['now']">selected="selected"</if> value="{$vv.name}">{$vv.name}</option>
                                                    </volist>
                                                    
                                                    
                                                </select>
                                            </td>
											<elseif condition="$key eq 'd6'" />
												<td>
                                                <select style="width: 100%; <if condition="$v.last_update eq 'true'">color:red</if>" name="last[]">
                                                    <option value="">选择类别</option>
                                                    <volist name="zn_type" id="pp">
                                                        <option <if condition="$pp['name'] eq $v['last']">selected="selected"</if> value="{$pp.name}">{$pp.name}</option>
                                                    </volist>
                                                </select>
                                            </td>

                                            <td>
                                                <select style="width: 100%; <if condition="$v.now_update eq 'true'">color:red</if>" name="now[]">
                                                    <option value="">选择类别</option>
                                                    <volist name="zn_type" id="pp">
                                                        <option <if condition="$pp['name'] eq $v['now']">selected="selected"</if> value="{$pp.name}">{$pp.name}</option>
                                                    </volist>
                                                </select>
                                            </td>
											<else />
												<td><input <if condition="$v.last eq '--'">readonly="readonly"</if>  style="width: 100%;<if condition="$v.last_update eq 'true'">color:red</if>" name="last[]" id="last_{$key}"
											onFocus="choose(<if condition="$v.catgory eq ''">'other'<else />'{$v.catgory}'</if>,'last_'+'{$key}')" value="{$v.last}" type="text" /></td>

											<td><input <if condition="$v.now eq '--'">readonly="readonly"</if>  style="width: 100%;<if condition="$v.now_update eq 'true'">color:red</if>" name="now[]" id="now_{$key}" 
											onFocus="choose(<if condition="$v.catgory eq ''">'other'<else />'{$v.catgory}'</if>,'now_'+'{$key}')" value="{$v.now}" type="text"  /></td>
											</if>
											


										</tr>
									</foreach>
									</tbody>
								</table>

							</div>
							<div class="footer">
								<p>补充说明：<span>{$info.remark}</span></p>
								<p>报送日期和方式：<span>2017年4月10日前，2,3,4季度于季后15日前，电子邮件和加盖公章的纸介质，季报</span></p>
								<p>
									<ul class="info">
										<li style="width: 25%;">
											单位负责人：<input style="width: 50%;" type="text"  name="fz" id="fz" value="{$info.fz}" />
										</li>
										<li style="width: 25%;">
											联系人：<input style="width: 50%;" type="text"  name="lx" id="lx" value="{$info.lx}" />
										</li>
										<li style="width: 25%;">
											填表人：<input style="width: 50%;" type="text"  name="tb" id="tb" value="{$info.tb}" />
										</li>
										<li style="width: 25%;">
											报出日期：{$info.add_time|date='Y',###}年{$info.add_time|date='m',###}月{$info.add_time|date='d',###}日
										</li>
									</ul>
								</p>
							</div>
						</div>
						<div class="clearFLoat">
							<button id="submit"><span class="myIcon">&#xe613;</span>上传数据</button>
							<!--<button id="export"><span class="myIcon">&#xe6c6;</span>下载表格</button>-->
						</div>
					</form>

				</div>

			</div>
		</div>

		<script type="text/javascript" src="__PUBLIC__/Home/js/list3.js"></script>
	</body>
<script>
        function choose(datatype,id){
            if (datatype == 'goods') {
                $('#goods').modal('show');
                $('#goodsadd').attr('data-id',id);
                return false;
            }else if(datatype == 'city'){
                $('#city').modal('show');
                $('#cityadd').attr('data-id',id);
                return false;
            }else if(datatype == 'country'){
                $('#country').modal('show');
                $('#countryadd').attr('data-id',id);
                return false;
            }
            
        }

        function CheckAll(form){
            for (var i=0;i<form.elements.length;i++){
                var e = form.elements[i];
                if (e.Name != 'chkAll'&&e.disabled==false)
                    e.checked = form.chkAll.checked;
            }
        }
        $('#countryadd').on('click',function(){
            var str = '';
            $.each($('input[name="country[]"]:checked'),function() {
                    str += $(this).val()+'、';
            });
            var id = $('#countryadd').attr('data-id');
            document.getElementById(id).value=str;
            $('#country').modal('hide');
        })

        $('#cityadd').on('click',function(){
            var str = '';
            $.each($('input[name="city[]"]:checked'),function() {
                    str += $(this).val()+'、';
            });
            var id = $('#cityadd').attr('data-id');
            document.getElementById(id).value=str;
            $('#city').modal('hide');
        })

        $('#goodsadd').on('click',function(){
            var str = '';
            $.each($('input[name="goods[]"]:checked'),function() {
                    str += $(this).val()+'、';
            });
            var id = $('#goodsadd').attr('data-id');
            document.getElementById(id).value=str;
            $('#goods').modal('hide');
        })



	$(function(){
		$('#form1').ajaxForm({
			beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
			success: complete, // 这是提交后的方法
			dataType: 'json'
		});

		$('#form2').ajaxForm({
			beforeSubmit: checkForm1, // 此方法主要是提交前执行的方法，根据需要设置
			success: complete, // 这是提交后的方法
			dataType: 'json'
		});

		$('#excel').change(function () {
			var filepath = $("input[name='excel']").val();
			var extStart = filepath.lastIndexOf(".");
			var ext = filepath.substring(extStart, filepath.length).toUpperCase();
			if (ext != ".XLS" && ext != ".XLSX") {
				layer.alert("excel限于xls,xlsx格式", {icon: 5});
				return false;
			}
			/*                file_size = this.files[0].size;
			 var size = file_size / 1024;
			 if (size > 10240) {
			 layer.alert("上传的excel大小不能超过10M！", {icon: 5});
			 return false;
			 }*/
		});
		
		function checkForm() {
			if ('' == $.trim($('#fz').val())){
				layer.alert("请填写单位负责人", {icon: 5},function(index){
					layer.close(index);
					$('#fz').focus();
				});
				return false;
			}
			if ('' == $.trim($('#lx').val())){
				layer.alert("请填写联系人", {icon: 5},function(index){
					layer.close(index);
					$('#lx').focus();
				});
				return false;
			}

			if ('' == $.trim($('#tb').val())){
				layer.alert("请填写填表人", {icon: 5},function(index){
					layer.close(index);
					$('#tb').focus();
				});
				return false;
			}

			if ('{$info.code}' == 'CDTLG411'){

				var info = check_411();
				if(info != ''){
					layer.alert(info, {icon: 5},function(index){
						layer.close(index);
					});
					return false;
				}
			}else if('{$info.code}' == 'CDTLG414'){

				var info = check_414();
				if(info != ''){
					layer.alert(info, {icon: 5},function(index){
						layer.close(index);
					});
					return false;
				}
			}else if('{$info.code}' == 'CDTLG410'){

				var info = check_410();

				if(info != ''){
					layer.alert(info, {icon: 5},function(index){
						layer.close(index);
					});
					return false;
				}
			}else if('{$info.code}' == 'CDTLG409'){
				var info = check_409();
				if(info != ''){
					layer.alert(info, {icon: 5},function(index){
						layer.close(index);
					});
					return false;
				}
			}
		}

		function checkForm1(){
			var filepath = $("input[name='excel']").val();
			var extStart = filepath.lastIndexOf(".");
			var ext = filepath.substring(extStart, filepath.length).toUpperCase();
			if (ext != ".XLS" && ext != ".XLSX") {
				layer.alert("excel限于xls,xlsx格式", {icon: 5});
				return false;
			}


			if ('' == $.trim($('#fz1').val())){
				layer.alert("请填写单位负责人", {icon: 5},function(index){
					layer.close(index);
					$('#fz1').focus();
				});
				return false;
			}
			if ('' == $.trim($('#lx1').val())){
				layer.alert("请填写联系人", {icon: 5},function(index){
					layer.close(index);
					$('#lx1').focus();
				});
				return false;
			}

			if ('' == $.trim($('#tb1').val())){
				layer.alert("请填写填表人", {icon: 5},function(index){
					layer.close(index);
					$('#tb1').focus();
				});
				return false;
			}
			/*file_size = this.files[0].size;
			 var size = file_size / 1024;
			 if (size > 10240) {
			 layer.alert("上传的excel大小不能超过10M！", {icon: 5});
			 return false;
			 }*/
		}
		function complete(data){
			if(data.status==1){
				layer.alert(data.info, {icon: 6}, function(index){
					layer.close(index);
					window.location.href=data.url;
				});
			}else{
				layer.alert(data.info, {icon: 6}, function(index){
					layer.close(index);
					return false;
				});
			}
		}

	});
</script>
</html>